
#pragma once

#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>

#include <iostream>

using namespace cv;

namespace course_02_basic
{

    void basic_functions(std::string imgPath)
    {

        Mat image = imread(imgPath);

        Mat imageHSV;
        Mat imageGray;

        cvtColor(image, imageHSV, COLOR_BGR2HSV);
        cvtColor(image, imageGray, COLOR_BGR2GRAY);

        imshow("IMAGE", image);
        imshow("IMAGE-HSV", imageHSV);
        imshow("IMAGE-Gray", imageGray);

        Mat imageBlur;
        Mat imgCanny;
        Mat imgDia;
        Mat imgErode;
        GaussianBlur(image, imageBlur, Size(7, 7), 5, 5); //高斯模糊
        Canny(imageBlur, imgCanny, 50, 150);              //边缘检测
        imshow("IMAGE-Blur", imageBlur);
        imshow("IMAGE-imgCanny", imgCanny);
        //边缘膨胀显示
        Mat kernel = getStructuringElement(MORPH_RECT, Size(5, 5));
        dilate(imgCanny, imgDia, kernel);
        imshow("IMAGE-Dialtation", imgDia);
        // imshow("IMAGE-Erode", imgErode);

        waitKey(0);
    }

}